<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initCarregamentoAutomatico ()
    {
        // instanciando um carregamento autolader do zend
        $carregamentoAutomatico = Zend_Loader_Autoloader::getInstance();
        //Registrando minhas namespaces
        $carregamentoAutomatico->registerNamespace('RSITE');
        $carregamentoAutomatico->registerNamespace('ZendX');
        return $carregamentoAutomatico;
    }
    protected function _initCarregandoPlugin ()
    {
        $bootstrap = $this->getApplication();
        if ($bootstrap instanceof Zend_Application) {
            $bootstrap = $this;
        }
        $bootstrap->bootstrap('FrontController');
        $front = $bootstrap->getResource('FrontController');
        $front->registerPlugin(new RSITE_Plugin_Layout());        
    }
    protected function _initConnection ()
    {
        // Obtem os resources(recursos).
        $options = $this->getOption('resources');
        $db_adapter = $options['db']['adapter'];
        $params = $options['db']['params'];
        try {
            $db = Zend_Db::factory($db_adapter, $params);
            $db->getConnection();
            // Registra a $db para que se torne acessivel em toda app
            $registro = Zend_Registry::getInstance();
            $registro->set('db', $db);
        } catch (Zend_Exception $e) {
            echo "Estamos sem conexão ao banco de dados neste momento. Tente mais tarde por favor.";
            exit();
        }
    }
    protected function _initPlaceHolders ()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->addHelperPath('RSITE/View/Helpers', 'RSITE_View_Helpers');
        $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
        $view->headScript()->appendFile('/js/validacoes.js');
        $view->headScript()->appendFile('/js/generico.js');
        $view->doctype('XHTML1_TRANSITIONAL');
        $view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
        $view->headTitle('Sender - Sistema de Campanhas Online')->setSeparator(' | ');
        Zend_Registry::set('view', $view);
    }
	public static function _initTranslate() {    
        $translator = new Zend_Translate(array('adapter' => 'array', 'content' => '../library/resources/languages', 'locale' => 'pt_BR', 'scan' => Zend_Translate::LOCALE_DIRECTORY));        
        Zend_Validate_Abstract::setDefaultTranslator ($translator);
        Zend_Registry::set('translator', $translator);
    }
    
   /* public static function _initAcl(){
    	$auth = Zend_Auth::getInstance();
    	$acl = new RSITE_Acl($auth);
    	$frontControler = Zend_Controller_Front::getInstance();
    	$frontControler->setParam('auth', $auth);
    	$frontControler->setParam('acl', $acl);
    	$frontControler->registerPlugin(new RSITE_Plugin_Acl($auth, $acl));
    	
    
    }*/
    
}

